<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>发起请求</button>
    <h1 id="app" style="display:none">我是界面</h1>
    <script src="./Promise封装请求方式.js"></script>

    <script>
        const btn = document.querySelector('button')
        const dom = document.querySelector('#app')
        btn.addEventListener('click', async function () {
            const res = await harryAjax({ method: 'GET', url: 'http://ajax-base-api-t.itheima.net/api/getbooks' })
            console.log(res);
        })
        Promise.all([
            harryAjax({ method: 'GET', url: 'http://ajax-base-api-t.itheima.net/api/getbooks'}),
            harryAjax({ method: 'POST',data:{bookname: 'promise',author: 'yuan',publisher:'111'}, url: 'http://ajax-base-api-t.itheima.net/api/addbook'}),
        ]).then(res=>{console.log(res)
        dom.style.display = 'block'})
        .catch(err=>{console.log(err)
        dom.style.display = 'block'
        dom.innerHTML = 404
    })
    </script>
</body>

</html>